<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏商家合作平台</title>
    <script src="__JS__/jquery.js"></script>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
</head>
<body>
{include file="base/header" /}
<div style="height: 5px"></div>
<button type="button" class="btn btn-info" id="index">查看通过的商品</button>
<div style="float: right; margin-top: 5px;margin-bottom: 5px" class="box-title ">
    <form class="form-inline" action="{:url('business/goods/examine')}" method="get">
        <input type="text" name="title" value="<?php if(isset($title)) echo $title ?>" class="form-control" id="exampleInputEmail3" >
        <input type="submit" class="btn btn-default" value="搜索"/>
        <input type="button" onclick="res()" value="全部显示" class="btn btn-default"/>
    </form>
</div>
<table class="layui-table" style="text-align: center">
    <thead>
    <tr>
        <td>商品名称</td>
        <td>类型</td>
        <td>单价(元)</td>
        <td>商品介绍</td>
        <!--<td>状态</td>-->
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    {foreach $result as $val}
        <tr id="del{$val.id}">
            <td>{$val.pname}</td>
            <td>{$val.category}</td>
            <td>{$val.purchaseprice}</td>
            <td onclick="introduct({$val.id})">{$val.introduce|substr=###,0,9}</td>
            <!--{if $val.status == 3}-->
                <!--<td style="color: #0d6aad">审核中</td>-->
            <!--{else /}-->
                <!--<td style="color: red">未通过</td>-->
            <!--{/if}-->
            <td>
                <button type="button" onclick="del({$val.id})" class="btn btn-danger btn-xs">删除</button>
                <button type="button" onclick="previewimage({$val.id})" class="btn btn-primary btn-xs">查看图片</button>
                <!--{if $val.status == 5}-->
                    <!--<button type="button" class="btn btn-warning btn-xs">查看原因</button>-->
                <!--{/if}-->
            </td>
        </tr>
    {/foreach}
    </tbody>
</table>
{$result->render()}
</body>
<script>
    //查看描述
    function introduct(id) {
        layer.open({
            type:2,
            title:"描述",
            anim:2,
            //maxmin:true,
            area: ['700px', '420px'],
            content:"{:url('business/goods/introduct')}?id="+id
        });
    }
    //查看通过的商品
    $("#index").click(function () {
        window.location.href = "{:url('business/goods/index')}";
    });
    //查看图片
    function previewimage(id) {
        layer.open({
            type:2,
            title:"图片",
            anim:2,
            //maxmin:true,
            area: ['500px', '400px'],
            content:"{:url('business/goods/previewimage')}?id="+id
        });
    }
    //删除
    function del(id) {
        layer.confirm('你确定要删除吗',{bnt:['确定','取消']},
            function () {
                $.ajax({
                    url: "{:url('business/goods/goodsdel')}",
                    data: "id=" + id,
                    type: "post",
                    dataType: "json",
                    success: function (res) {
                        if (res.success) {
                            layer.alert(res.success);
                            $("#del" + id).remove();
                        }
                        if (res.error) {
                            layer.error(res.error);
                        }
                    }
                });
            }
        );
    }
    //全部显示
    function res() {
        window.location.href = "{:url('business/goods/examine')}";
    }
</script>
</html>